package com.dangf.app.launcher.adapter

import android.view.View
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.dangf.app.launcher.R
import com.dangf.app.launcher.app.V
import com.dangf.app.launcher.entity.Soft
import com.haozhang.lib.SlantedTextView
import pw.hais.utils_lib.utils.AppUtils

/**
 * Created by hais1992 on 2017/9/9/009.
 */
class MainAppListAdapter(list: List<Soft>) : BaseQuickAdapter<Soft, BaseViewHolder>(R.layout.item_applist, list) {

    override fun convert(helper: BaseViewHolder?, item: Soft?) {
        helper?.setText(R.id.text_app_name, item?.name)
        Glide.with(mContext).load(V.HTTP_FILE_URL + item?.icon).into(helper?.getView(R.id.text_app_icon))

        if (!AppUtils.isInstallApp(item?.packageName!!) && !item.packageName.contains("com.dangf.app")) {
            helper?.getView<SlantedTextView>(R.id.slanted_text_tag)?.visibility = View.VISIBLE
        }
    }

}